<template>
  <div class="authorization">
    <!-- 顶部头像 -->
    <div class="topOfperson">
      <img class="headImg" v-if="getTokenByStorage" :src="userInfo.avatarUrl" alt />
      <img class="headImg" @click="getToken" v-else src="/static/images/wdl.png" alt />
      <div class="username">
        <span v-if="!getTokenByStorage">点击头像登录</span>
        <span v-else>{{userInfo.nickName}}</span>
      </div>
    </div>
    <div class="fatline" />
    <div class="ablock">
      <div class="texts" @click="building">
        <img class="miniImg" src="/static/icon/like.png" alt />
        <span>我喜欢的</span>
      </div>
      <div class="alineW" />
      <div class="texts" @click="building">
        <img class="miniImg" src="/static/icon/has.png" alt />
        <span>我看过的</span>
      </div>
    </div>
    <div class="fatline" />
  </div>
</template>

<script>
import { navto } from "@/utils/util";
import { toast } from "@/utils/index";
export default {
  data() {
    return {
      getTokenByStorage: false, //是否获得了token
      userInfo: {} //用户信息
    };
  },
  onShow() {
    let that = this;
    let token = mpvue.getStorageSync("token") || "";
    if (token) {
      that.getTokenByStorage = true;
      that.userInfo = mpvue.getStorageSync("userInfo");
    } else {
      that.getTokenByStorage = false;
    }
  },
  methods: {
    getToken() {
      // 跳转回授权页面
      navto("/pages/authorization/main", "");
    },
    building(){
      toast("正在建设中，敬请期待！")
    }
  }
};
</script>

<style lang='less' scope>
.authorization {
  width: 100%;
  border-top: 1rpx #c7c5c5 solid;
  box-sizing: border-box;
  background-color: #fff;
  .topOfperson {
    width: 100%;
    height: 420rpx;
    background-color: rgb(71, 71, 71);
    display: flex;
    flex-direction: row;
    .headImg {
      margin: auto 55rpx;
      width: 150rpx;
      height: 150rpx;
      border-radius: 50%;
    }
    .username {
      position: relative;
      margin: auto 15rpx;
      color: #fff;
    }
  }
  .ablock {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 32rpx 55rpx;
    .texts {
      width: 100%;
      font-size: 26rpx;
      display: flex;
      flex-direction: row;
      .miniImg {
        margin: auto 5rpx;
        width: 42rpx;
        height: 42rpx;
      }
      span {
        position: relative;
        margin: auto 25rpx;
      }
    }
  }
  .p1 {
    font-size: 36rpx;
    font-weight: bold;
    color: #333;
    margin-bottom: 40rpx;
    font-weight: 400;
  }
  .p2 {
    font-size: 46rpx;
    font-weight: 700;
    color: rgb(40, 19, 233);
    margin-bottom: 80rpx;
    font-weight: 400;
  }
}
</style>
